import request from '@/utils/request'

// 使用模拟数据响应
const useMockData = true;

// 查询标准列表
export function listStandard(query) {
  if (useMockData) {
    return Promise.resolve({
      code: 200,
      rows: mockData.standardList,
      total: mockData.standardList.length
    });
  }
  
  return request({
    url: '/qep/standard/list',
    method: 'get',
    params: query
  })
}

// 查询标准详细
export function getStandard(id) {
  if (useMockData) {
    return Promise.resolve({
      code: 200,
      data: mockData.standardDetail
    });
  }
  
  return request({
    url: '/qep/standard/' + id,
    method: 'get'
  })
}

// 新增标准
export function addStandard(data) {
  if (useMockData) {
    return Promise.resolve({
      code: 200,
      msg: "操作成功"
    });
  }
  
  return request({
    url: '/qep/standard',
    method: 'post',
    data: data
  })
}

// 修改标准
export function updateStandard(data) {
  if (useMockData) {
    return Promise.resolve({
      code: 200,
      msg: "操作成功"
    });
  }
  
  return request({
    url: '/qep/standard',
    method: 'put',
    data: data
  })
}

// 删除标准
export function delStandard(id) {
  if (useMockData) {
    return Promise.resolve({
      code: 200,
      msg: "操作成功"
    });
  }
  
  return request({
    url: '/qep/standard/' + id,
    method: 'delete'
  })
}

// 搜索标准列表
export function searchStandard(query) {
  if (useMockData) {
    return Promise.resolve({
      code: 200,
      data: mockData.standardList
    });
  }
  
  return request({
    url: '/qep/standard/search',
    method: 'get',
    params: query
  })
}

// 查询标准参数
export function listStandardParam(standardId) {
  if (useMockData) {
    return Promise.resolve({
      code: 200,
      data: mockData.standardParams
    });
  }
  
  return request({
    url: '/qep/standard/param/list',
    method: 'get',
    params: { standardId: standardId }
  })
} 